/**
  @Author: 王炜皓
  @Date: 2023-05-22 14:23:23
  @LastEditTime: 2023-05-22 20:15:59
  @LastEditors: 王炜皓
  @Description: 高德地图类
  @FilePath: \utum-cesium\src\views\test\extend\AmapImageryLayerProvider\AmapMercatorTilingScheme.js
 **/

 
import CoordTransform from "../CoodTransform";
const Cesium = window.Cesium;
class AmapMercatorTilingScheme extends Cesium.WebMercatorTilingScheme {
  constructor(options) {
    super(options);
    let projection = new Cesium.WebMercatorProjection();
    this._projection.project = function (cartographic, result) {
      result = CoordTransform.WGS84ToGCJ02(
        Cesium.Math.toDegrees(cartographic.longitude),
        Cesium.Math.toDegrees(cartographic.latitude)
      );
      result = projection.project(
        new Cesium.Cartographic(
          Cesium.Math.toRadians(result[0]),
          Cesium.Math.toRadians(result[1])
        )
      );
      return new Cesium.Cartesian2(result.x, result.y);
    };
    this._projection.unproject = function (cartesian, result) {
      let cartographic = projection.unproject(cartesian);
      result = CoordTransform.GCJ02ToWGS84(
        Cesium.Math.toDegrees(cartographic.longitude),
        Cesium.Math.toDegrees(cartographic.latitude)
      );
      return new Cesium.Cartographic(
        Cesium.Math.toRadians(result[0]),
        Cesium.Math.toRadians(result[1])
      );
    };
  }
}
 
export default AmapMercatorTilingScheme;